<!DOCTYPE html>
<html lang='en'>
<head>
  <meta charset='UTF-8'>
  <title>Title</title>
</head>
<body>
<input type='text'>
<script>
  let timeId
  const input = document.querySelector('input')
  input.addEventListener('input', function() {
    if (timeId) {
      clearTimeout(timeId)
    }
    timeId = setTimeout(() => {
      console.log('发送请求', this.value)
    }, 500)
  })
</script>
</body>
</html>
